package com.caldera.vaquita;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class VaquitaActivity extends Activity {
	VaquitaUtils utils;
	VaquitaData data;
	SQLiteDatabase db;
	Cursor rs;
	String sql;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		utils = new VaquitaUtils(this);
		data = new VaquitaData(this);
		db = data.getReadableDatabase();
		sql = "select _id, nombre, pmes, pdia, simbolo from conf;";
		rs = db.rawQuery(sql, null);
		if (rs.moveToNext()) {
			((TextView) findViewById(R.id.confName)).setText(rs.getString(1));
			((TextView) findViewById(R.id.confState)).setText(rs.getString(4)
					+ " " + utils.getSaldo(utils.getFecha("yyyy-MM")));
		}

	}

	public void onAdd(View v) {
		/*
		 * Intent intent = new Intent(); intent.setClass(this,
		 * CheckERCajaFm.class); intent.putExtra("opt", "add");
		 * startActivity(intent);
		 */
		startActivity(new Intent(this, VaquitaCajaFm.class));
	}

	public void onReport(View v) {
		startActivity(new Intent(this, VaquitaCajaReport.class));
	}

	public void onConf(View v) {
		startActivity(new Intent(this, VaquitaConf.class));
	}

	public void onFinish(View v) {
		finish();
	}

	public void onHistorial(View v) {
		startActivity(new Intent(this, VaquitaHistorial.class));
	}
}